package com.fxd.crm.service.impl.teachImpl;

import com.fxd.crm.mapper.CourseOrderMapper;
import com.fxd.crm.mapper.teachMapper;
import com.fxd.crm.model.CourseOrder;
import com.fxd.crm.model.PageResult;
import com.fxd.crm.model.teach;
import com.fxd.crm.service.ITeachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther fuxudong
 * @date 2021/4/5 - 11:08
 */
@Service
public class teachImpl implements ITeachService {
    @Autowired
    teachMapper teachMapper;


    @Override
    public PageResult<teach> findPageResult(teach teach, int Page, int PageSize) {
        PageResult<teach> result = new PageResult<>();
        result.setCode(0);
        Map<String, Object> params = new HashMap<>();
        params.put("condition",teach);
        params.put("start",(Page-1)*PageSize);
        params.put("pageSize",PageSize);
        int count = teachMapper.findCountByMap(params);
        result.setCount(count);
        //获取查询的数据
        List<teach> list = teachMapper.findListByMap(params);
        result.setData(list);
        return result;
    }

    @Override
    public void save(teach teach) {
        teachMapper.insert(teach);
    }

    @Override
    public teach findByOrderId(Integer teach_id) {
        teach teach = teachMapper.findByOrderId(teach_id);
        return teach;
    }

    @Override
    public void deleteByOrderId(Integer teach_id) {
        teachMapper.deleteByOrderId(teach_id);
    }

    @Override
    public void update(teach teach) {
        teachMapper.update(teach);
    }
}
